package com.loongtech.bi.manager.pay;

import com.loongtech.bi.action.PageHelper;
import com.loongtech.bi.action.UIHelper;
import com.loongtech.bi.action.pay.OverviewPayAction;
import com.loongtech.bi.entity.pay.EntityNewUserLTV;
import com.loongtech.bi.entity.pay.EntityPayUser;
import com.loongtech.bi.entity.pay.EntityTotalCash;
import com.loongtech.bi.entity.player.EntityDau;
import com.loongtech.bi.manager.flow.HadoopQueryManager;
import com.loongtech.bi.manager.player.DauManager;
import com.loongtech.bi.manager.player.NewUserManager;
import com.loongtech.bi.manager.system.BiPlatformManager;
import com.loongtech.bi.support.Helper;
import com.loongtech.bi.support.chart.ChartData1;
import com.loongtech.bi.support.chart.ChartFlow;
import com.loongtech.bi.support.chart.ChartSelect;
import com.loongtech.core.jpa.manager.ManagerQueryCacheBase;
import com.loongtech.core.util.Time;
import com.loongtech.core.util.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.Map.Entry;

/**
 * 付费分析 —付费收入manager
 * 
 * @author marin
 * @date 2015-09-15
 */
@Service
public class OverviewPayManager extends ManagerQueryCacheBase<Object> {
	private static final long serialVersionUID = 1L;
	
	@Autowired
	DauManager dauManager;
	@Autowired
	TotalCashManager totalCashManager;
	@Autowired
	PayUserManager payUserManager;
	@Autowired
	NewUserLTVManager newUserLTVManager;
	@Autowired
	NewUserManager newUserManager;
	@Autowired
	HadoopQueryManager hadoopQueryManager;
	
	// 查询付费收入总体数据
	public OverviewPayData getOverviewPayData(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer) {
		OverviewPayData result = new OverviewPayData();
		
		// 活跃人数
		List<EntityDau> list1 = dauManager.getAllDauByAllKind(dateStart, dateEnd, queryPlatform, queryChannel, queryServer);
		if (!Helper.isEmptyValue(list1)) {
			for (EntityDau o : list1) {
				result.setActiveUser(o.getDau());
			}
		}
		
		// 付费金额
		List<EntityTotalCash> list2 = totalCashManager.getAllTotalCashByAllKind(dateStart, dateEnd, queryPlatform, queryChannel, queryServer);
		if (!Helper.isEmptyValue(list2)) {
			for (EntityTotalCash o : list2) {
				result.setPayCount(result.getPayCount() + o.getTotal_cash());
			}
			result.setPayCount(UIHelper.getYuan(result.getPayCount()));
		}
		
		// 付费账号数
		List<EntityPayUser> list3 = payUserManager.getAllPayUserByAllKind(dateStart, dateEnd, queryPlatform, queryChannel, queryServer);
		if (!Helper.isEmptyValue(list3)) {
			for (EntityPayUser o : list3) {
				result.setPayUser(o.getAddcash_user());
			}
		}
		
		// 付费渗透率
		result.setPayInRadio(result.getActiveUser() == 0 ? 0 : (float)(result.getPayUser() * 1.0 / (result.getActiveUser())));
		
		// 活跃ARPU
		result.setActiveARPU(result.getActiveUser() == 0 ? 0 : PageHelper.floatKeepTwoNumber(result.getPayCount() * 1.0 / (result.getActiveUser())));
		
		// 付费ARPU
		result.setPayARPU(result.getPayUser() == 0 ? 0 : PageHelper.floatKeepTwoNumber(result.getPayCount() * 1.0 / (result.getPayUser())));
		
		return result;
	}
	
	// 查询付费趋势数据
	public List<PayTrendData> getPayTrendData(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer) {
		Map<String, PayTrendData> resultMap = new LinkedHashMap<>();
		
		// 活跃用户
		List<EntityDau> list1 = dauManager.getDauByAllKind(dateStart, dateEnd, queryPlatform, queryChannel, queryServer);
		if (list1 != null && list1.size() > 0) {
			for(EntityDau o : list1) {
				String key = o.getStartday();
				int value = o.getDau();
				
				PayTrendData tmp = resultMap.get(key);
				if (tmp == null) {
					tmp = new PayTrendData();
					tmp.setDateStr(key);
					tmp.setPlatformId(o.getPlatformid());
					tmp.setChannelId(o.getChannelid());
					tmp.setServerId(o.getServerid());
					resultMap.put(key, tmp);
				}
				tmp.setActiveUser(value);
			}
		}
		
		// 付费金额
		List<EntityTotalCash> list2 = totalCashManager.getAllTotalCashByAllKind(dateStart, dateEnd, queryPlatform, queryChannel, queryServer);
		if (list2 != null && list2.size() > 0) {
			for(EntityTotalCash o : list2) {
				String key = Time.getDateStr(o.getDay());
				int value = UIHelper.getYuan(o.getTotal_cash());
				
				PayTrendData tmp = resultMap.get(key);
				if (tmp == null) {
					tmp = new PayTrendData();
					tmp.setDateStr(key);
					tmp.setPlatformId(o.getPlatformid());
					tmp.setChannelId(o.getChannelid());
					tmp.setServerId(o.getServerid());
					resultMap.put(key, tmp);
				}
				tmp.setPayCount(value);
			}
		}
		
		// 付费人数
		List<EntityPayUser> list3  = payUserManager.getTheAllPayUserByAllKind(dateStart, dateEnd, queryPlatform, queryChannel, queryServer);
		if (list3 != null && list3.size() > 0) {
			for(EntityPayUser o : list3) {
				String key = o.getStartday();
				int value = o.getAddcash_user();
				
				PayTrendData tmp = resultMap.get(key);
				if (tmp == null) {
					tmp = new PayTrendData();
					tmp.setDateStr(key);
					tmp.setPlatformId(o.getPlatformid());
					tmp.setChannelId(o.getChannelid());
					tmp.setServerId(o.getServerid());
					resultMap.put(key, tmp);
				}
				tmp.setPayUser(value);
			}
		}
		
		for (Entry<String, PayTrendData> entry : resultMap.entrySet()) {
			PayTrendData v = entry.getValue();
			// 付费渗透率
			v.setPayInRadio((float)(v.getPayUser() * 1.0 / (v.getActiveUser() == 0 ? 1 : v.getActiveUser())));
			// 活跃ARPU
			v.setActiveARPU(PageHelper.floatKeepTwoNumber(v.getPayCount() * 1.0 / (v.getActiveUser() == 0 ? 1 : v.getActiveUser())));
			// 付费ARPU
			v.setPayARPU(PageHelper.floatKeepTwoNumber(v.getPayCount() * 1.0 / (v.getPayUser() == 0 ? 1 : v.getPayUser())));
		}
		
		ArrayList<PayTrendData> result = new ArrayList<PayTrendData>(resultMap.values());
		Collections.sort(result, new PayTrendData().comparatorDate);
		
		return result;
	}
	
	// 查询付费分类数据
	public List<PayClassData> getPayClassData(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer) {
		List<PayClassData> result = new ArrayList<>();
		
		// 总活跃人数
		int sumActiveUser = 0;
		List<EntityDau> list0 = dauManager.getAllDauByAllKind(dateStart, dateEnd, queryPlatform, queryChannel, queryServer);
		if (!Helper.isEmptyValue(list0)) {
			for (EntityDau o : list0) {
				sumActiveUser += o.getDau();
			}
		}
		if (sumActiveUser <= 0) {
			return result;
		}
		
		int sumNewActiveUser = 0;
		// 新增帐号，即新增活跃
		List<Object[]> list00 = newUserManager.getNewUserByAllKind(dateStart, dateEnd, queryPlatform, queryChannel, queryServer);
		for(Object[] o : list00) {
			sumNewActiveUser += Integer.parseInt(o[1].toString());
		}
		
		// 计算付费玩家数和额度的总数
		int sumCash = 0;  // 总充值
		int sumPayUser = 0;  // 总充值人数
		List<EntityTotalCash> list1 = totalCashManager.getAllTotalCashByAllKind(dateStart, dateEnd, queryPlatform, queryChannel, queryServer);
		List<EntityPayUser> list2 = payUserManager.getAllPayUserByAllKind(dateStart, dateEnd, queryPlatform, queryChannel, queryServer);
		for (EntityTotalCash e : list1) {
			sumCash += e.getTotal_cash();
		}
		for (EntityPayUser e : list2) {
			sumPayUser += e.getAddcash_user();
		}
		
		// 计算新付费玩家数和新付费额度数
		int newCash = 0;
		int newPayUser = 0;
		List<EntityNewUserLTV> list = newUserLTVManager.getAllNewUserLTVByAllKind(dateStart, dateEnd, queryPlatform, queryChannel, queryServer);
		for (EntityNewUserLTV e : list) {
			newCash += e.getCashadd();
			newPayUser += e.getAddcash_user();
		}
		
		PayClassData p1 = new PayClassData();
		p1.setClassStr("新用户");
		p1.setPayCount(UIHelper.getYuan(newCash));
		p1.setPayUser(newPayUser);
		p1.setActiveUser(sumNewActiveUser);
		p1.setPayInRadio(p1.getActiveUser() == 0 ? 0 : (float)(p1.getPayUser() * 1.0 / (p1.getActiveUser())));
		p1.setActiveARPU(p1.getActiveUser() == 0 ? 0 : PageHelper.floatKeepTwoNumber(p1.getPayCount() * 1.0 / (p1.getActiveUser())));
		p1.setPayARPU(p1.getPayUser() == 0 ? 0 : PageHelper.floatKeepTwoNumber(p1.getPayCount() * 1.0 / (p1.getPayUser())));
		PayClassData p2 = new PayClassData();
		p2.setClassStr("老用户");
		p2.setPayCount(UIHelper.getYuan(sumCash - newCash));
		p2.setPayUser(sumPayUser - newPayUser);
		p2.setActiveUser(sumActiveUser - sumNewActiveUser);
		p2.setPayInRadio(p2.getActiveUser() == 0 ? 0 : (float)(p2.getPayUser() * 1.0 / (p2.getActiveUser())));
		p2.setActiveARPU(p2.getActiveUser() == 0 ? 0 : PageHelper.floatKeepTwoNumber(p2.getPayCount() * 1.0 / (p2.getActiveUser())));
		p2.setPayARPU(p2.getPayUser() == 0 ? 0 : PageHelper.floatKeepTwoNumber(p2.getPayCount() * 1.0 / (p2.getPayUser())));

		result.add(p1);
		result.add(p2);
		
		return result;
	}
	
	// 查询付费区间数据
	public static Map<Integer, String> rangeMap = new HashMap<Integer, String>() {
		private static final long serialVersionUID = 1L;
		{
			put(1, "(1,2]");put(10, "(2,10]");put(20, "(10,20]");put(50, "(20,50]");
			put(100, "(50,100]");put(200, "(100,200]");put(500, "(200,500]");
			put(1000, "(500,1000]");put(5000, "(1000,5000]");put(10000, "5000+");
		}
	};
	public List<PayRangeData> getPayRangeData(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer) {
		Map<String, PayRangeData> resultMap = new LinkedHashMap<>();
		
		StringBuffer sql = new StringBuffer();
		sql.append("select userid,sum(cashadd) as cashadd from addcash where cashadd != null and 1=1 ");
		sql.append(" and dt >= '");
		sql.append(Time.getDateStr(dateStart));
		sql.append("' and dt <= '");
		sql.append(Time.getDateStr(dateEnd));
		sql.append("' ");
		if (!"0".equals(queryPlatform)) {
			sql.append(" and platform = ");
			sql.append(queryPlatform);
		}
		if (!"0".equals(queryChannel)) {
			sql.append(" and channel = '");
			sql.append(queryChannel);
			sql.append("' ");
		}
		if (!"0".equals(queryServer)) {
			sql.append(" and serverid = ");
			sql.append(queryServer);
		}
		sql.append(" group by userid ");
		Entry<List<String>, List<Object[]>> ret = hadoopQueryManager.executeSQL(sql.toString());
		if (null != ret && null != ret.getKey() && !ret.getKey().isEmpty() && null != ret.getValue() && !ret.getValue().isEmpty()) {
			int sumPayCount = 0;
			int sumPayUser = 0;
			
			List<Object[]> vs = ret.getValue();
			for (Object[] os : vs) {
				int cashadd = UIHelper.getYuan(Integer.parseInt(os[1].toString()));
				
				int key = getKey(cashadd);
				String range = rangeMap.get(key);
				PayRangeData o = resultMap.get(range);
				if (o == null) {
					o = new PayRangeData();
					o.setRangeStr(range);
					o.setKey(key);
					resultMap.put(range, o);
				}
				o.setPayCount(o.getPayCount() + cashadd);
				o.setPayUser(o.getPayUser() + 1);
				
				sumPayCount += cashadd;
				sumPayUser += 1;
			}
			
			for (Entry<String, PayRangeData> entry : resultMap.entrySet()) {
				PayRangeData p = entry.getValue();
				p.setPayCountRadio(sumPayCount == 0 ? 0 : (float)(p.getPayCount() * 1.0 / sumPayCount));
				p.setPayUserRadio(sumPayUser == 0 ? 0 : (float)(p.getPayUser() * 1.0 / sumPayUser));
			}
			
			ArrayList<PayRangeData> result = new ArrayList<PayRangeData>(resultMap.values());
			Collections.sort(result, new PayRangeData().comparatorKey);
			
			return result;
		} else {
			return null;
		}
	}
	private int getKey(int count) {
		int result = 1;
		
		if (count <= 2) {
			result = 1;
		} else if (count <= 10) {
			result = 10;
		} else if (count <= 20) {
			result = 20;
		} else if (count <= 50) {
			result = 50;
		} else if (count <= 100) {
			result = 100;
		} else if (count <= 200) {
			result = 200;
		} else if (count <= 500) {
			result = 500;
		} else if (count <= 1000) {
			result = 1000;
		} else if (count <= 5000) {
			result = 5000;
		} else if (count > 50000) {
			result = 10000;
		} 
		
		return result;
	}
	
	// 查询付费对比数据 
	public List<PayCompareData> getPayCompareData(String compareTab, Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer) {
		Map<String, PayCompareData> resultMap = new LinkedHashMap<>();
		
		int sumPayCount = 0;
		int sumPayUser = 0;
		List<EntityTotalCash> list1 = null;  // 付费金额
		List<EntityPayUser> list2 = null;  // 付费账号数
		
		boolean isAllPCS = Utils.isAllPCS(queryPlatform, queryChannel, queryServer);  // 查询条件是否为全平台全渠道全区服
		if (isAllPCS) {  // 全服-此时要显示全对比
			list1 = totalCashManager.getTotalCashByDate(dateStart, dateEnd);
			list2 = payUserManager.getAllPayUserByDate(dateStart, dateEnd);
		} else {
			list1 = totalCashManager.getAllTotalCashByAllKind(dateStart, dateEnd, queryPlatform, queryChannel, queryServer);
			list2 = payUserManager.getAllPayUserByAllKind(dateStart, dateEnd, queryPlatform, queryChannel, queryServer);
		}
		
		for (EntityTotalCash o : list1) {
			String key = OverviewPayAction.platformCompareTab.equals(compareTab) ? o.getPlatformid() : (OverviewPayAction.channelCompareTab.equals(compareTab) ? o.getChannelid() : o.getServerid());
			String classStr = OverviewPayAction.platformCompareTab.equals(compareTab) ? BiPlatformManager.getPlatformNameById(key) : (OverviewPayAction.channelCompareTab.equals(compareTab) ? BiPlatformManager.getChannelNameById(key) : BiPlatformManager.getServerNameById(key));
			if (Utils.isAllPCS(o.getPlatformid(), o.getChannelid(), o.getServerid())) {  // 查出来的结果为全
				if (isAllPCS) {  // 查询条件为全
					sumPayCount += o.getTotal_cash();
				}
			} else {
				if (!"0".equals(key)) {
					PayCompareData tmp = resultMap.get(key);
					if (tmp == null) {
						tmp = new PayCompareData();
						tmp.setClassStr(classStr);
						resultMap.put(key, tmp);
					}
					tmp.setPayCount(tmp.getPayCount() + o.getTotal_cash());
					sumPayCount += o.getTotal_cash();
				}
			}
		}
		
		for (EntityPayUser o : list2) {
			String key = OverviewPayAction.platformCompareTab.equals(compareTab) ? o.getPlatformid() : (OverviewPayAction.channelCompareTab.equals(compareTab) ? o.getChannelid() : o.getServerid());
			String classStr = OverviewPayAction.platformCompareTab.equals(compareTab) ? BiPlatformManager.getPlatformNameById(key) : (OverviewPayAction.channelCompareTab.equals(compareTab) ? BiPlatformManager.getChannelNameById(key) : BiPlatformManager.getServerNameById(key));
			if (Utils.isAllPCS(o.getPlatformid(), o.getChannelid(), o.getServerid())) {  // 查出来的结果为全
				if (isAllPCS) {  // 查询条件为全
					sumPayUser += o.getAddcash_user();
				}
			} else {
				if (!"0".equals(key)) {
					PayCompareData tmp = resultMap.get(key);
					if (tmp == null) {
						tmp = new PayCompareData();
						tmp.setClassStr(classStr);
						resultMap.put(key, tmp);
					}
					tmp.setPayUser(tmp.getPayUser() + o.getAddcash_user());
					sumPayUser += o.getAddcash_user();
				}
			}
		}
		
		// 整理最终数据
		for (Entry<String, PayCompareData> entry : resultMap.entrySet()) {
			PayCompareData v = entry.getValue();
			v.setPayCount(UIHelper.getYuan(v.getPayCount()));
			v.setPayUser(v.getPayUser());
			
			v.setPayCountRadio(sumPayCount == 0 ? 0 : (float)(v.getPayCount() * 1.0 / UIHelper.getYuan(sumPayCount)));
			v.setPayUserRadio(sumPayUser == 0 ? 0 : (float)(v.getPayUser() * 1.0 / sumPayUser));
		}
		ArrayList<PayCompareData> result = new ArrayList<PayCompareData>(resultMap.values());
		Collections.sort(result, new PayCompareData().comparatorClass);
		
		return result;
	}
	
	// 付费收入总体数据
	public class OverviewPayData {
		private int activeUser; // 活跃人数
		private long payCount; // 付费金额
		private int payUser; // 付费人数
		private float payInRadio; // 付费渗透效率
		private float activeARPU; // 活跃ARPU
		private float payARPU; // 付费ARPU

		public int getActiveUser() {
			return activeUser;
		}

		public void setActiveUser(int activeUser) {
			this.activeUser = activeUser;
		}

		public long getPayCount() {
			return payCount;
		}

		public void setPayCount(long payCount) {
			this.payCount = payCount;
		}

		public int getPayUser() {
			return payUser;
		}

		public void setPayUser(int payUser) {
			this.payUser = payUser;
		}

		public float getPayInRadio() {
			return payInRadio;
		}

		public void setPayInRadio(float payInRadio) {
			this.payInRadio = payInRadio;
		}

		public float getActiveARPU() {
			return activeARPU;
		}

		public void setActiveARPU(float activeARPU) {
			this.activeARPU = activeARPU;
		}

		public float getPayARPU() {
			return payARPU;
		}

		public void setPayARPU(float payARPU) {
			this.payARPU = payARPU;
		}
	}
	
	// 付费趋势数据类，Chart类
	public class PayTrendData {
		@ChartFlow(name="日期")
		private String dateStr;
		private String platformId;
		private String channelId;
		private String serverId;
		private int activeUser;  // 活跃用户
		@ChartSelect(name = "付费金额", key = 1)
		@ChartData1(name = "付费金额", key = 1)
		private int payCount; // 付费金额
		@ChartSelect(name = "付费人数", key = 2)
		@ChartData1(name = "付费人数", key = 2)
		private int payUser; // 付费人数
		@ChartSelect(name = "付费渗透效率", key = 3)
		@ChartData1(name = "付费渗透效率", key = 3)
		private float payInRadio; // 付费渗透效率
		@ChartSelect(name = "活跃ARPU", key = 4)
		@ChartData1(name = "活跃ARPU", key = 4)
		private float activeARPU; // 活跃ARPU
		@ChartSelect(name = "付费ARPU", key = 5)
		@ChartData1(name = "付费ARPU", key = 5)
		private float payARPU; // 付费ARPU
		
		// 根据日期排序的比较器
		public final Comparator<PayTrendData> comparatorDate = new Comparator<PayTrendData>() {
			public int compare(PayTrendData s1, PayTrendData s2) {
				return s2.getDateStr().compareTo(s1.getDateStr());
			}
		};

		public String getDateStr() {
			return dateStr;
		}

		public void setDateStr(String dateStr) {
			this.dateStr = dateStr;
		}

		public int getPayCount() {
			return payCount;
		}

		public void setPayCount(int payCount) {
			this.payCount = payCount;
		}

		public int getPayUser() {
			return payUser;
		}

		public void setPayUser(int payUser) {
			this.payUser = payUser;
		}

		public float getPayInRadio() {
			return payInRadio;
		}

		public void setPayInRadio(float payInRadio) {
			this.payInRadio = payInRadio;
		}

		public float getActiveARPU() {
			return activeARPU;
		}

		public void setActiveARPU(float activeARPU) {
			this.activeARPU = activeARPU;
		}

		public float getPayARPU() {
			return payARPU;
		}

		public void setPayARPU(float payARPU) {
			this.payARPU = payARPU;
		}

		public int getActiveUser() {
			return activeUser;
		}

		public void setActiveUser(int activeUser) {
			this.activeUser = activeUser;
		}

		public String getPlatformId() {
			return platformId;
		}

		public void setPlatformId(String platformId) {
			this.platformId = platformId;
		}

		public String getChannelId() {
			return channelId;
		}

		public void setChannelId(String channelId) {
			this.channelId = channelId;
		}

		public String getServerId() {
			return serverId;
		}

		public void setServerId(String serverId) {
			this.serverId = serverId;
		}
	}
	
	// 付费分类数据类，Chart类
	public class PayClassData {
		@ChartFlow(name = "玩家分类")
		private String classStr;  // 新用户-老用户
		@ChartSelect(name = "付费金额", key = 1)
		@ChartData1(name = "付费金额", key = 1)
		private int payCount; // 付费金额
		@ChartSelect(name = "付费人数", key = 2)
		@ChartData1(name = "付费人数", key = 2)
		private int payUser; // 付费人数
		@ChartSelect(name = "活跃人数", key = 3)
		@ChartData1(name = "活跃人数", key = 3)
		private int activeUser;  // 活跃人数
		private float payInRadio;  //　付费渗透率
		private float activeARPU;  // 活跃ARPU
		private float payARPU;  // 付费ARPU

		public String getClassStr() {
			return classStr;
		}

		public void setClassStr(String classStr) {
			this.classStr = classStr;
		}

		public int getPayCount() {
			return payCount;
		}

		public void setPayCount(int payCount) {
			this.payCount = payCount;
		}

		public int getPayUser() {
			return payUser;
		}

		public void setPayUser(int payUser) {
			this.payUser = payUser;
		}

		public int getActiveUser() {
			return activeUser;
		}

		public void setActiveUser(int activeUser) {
			this.activeUser = activeUser;
		}

		public float getPayInRadio() {
			return payInRadio;
		}

		public void setPayInRadio(float payInRadio) {
			this.payInRadio = payInRadio;
		}

		public float getActiveARPU() {
			return activeARPU;
		}

		public void setActiveARPU(float activeARPU) {
			this.activeARPU = activeARPU;
		}

		public float getPayARPU() {
			return payARPU;
		}

		public void setPayARPU(float payARPU) {
			this.payARPU = payARPU;
		}
	}
	
	// 付费区间数据类，Chart类
	public class PayRangeData {
		@ChartFlow(name="区间")
		private String rangeStr; // 区间
		private int key;  // 用于排序
		private int payUser; // 付费人数
		@ChartSelect(name = "比例", key = 1)
		@ChartData1(name = "付费人数比例", key = 1)
		private float payUserRadio; // 付费人数比例
		private int payCount; // 付费金额
		@ChartData1(name = "付费金额比例", key = 1)
		private float payCountRadio; // 付费金额比例

		public final Comparator<PayRangeData> comparatorKey = new Comparator<PayRangeData>() {
			public int compare(PayRangeData s1, PayRangeData s2) {
				return new Integer(s2.getKey()).compareTo(new Integer(s1.getKey()));
			}
		};
		
		public String getRangeStr() {
			return rangeStr;
		}

		public void setRangeStr(String rangeStr) {
			this.rangeStr = rangeStr;
		}

		public int getPayUser() {
			return payUser;
		}

		public void setPayUser(int payUser) {
			this.payUser = payUser;
		}

		public float getPayUserRadio() {
			return payUserRadio;
		}

		public void setPayUserRadio(float payUserRadio) {
			this.payUserRadio = payUserRadio;
		}

		public int getPayCount() {
			return payCount;
		}

		public void setPayCount(int payCount) {
			this.payCount = payCount;
		}

		public float getPayCountRadio() {
			return payCountRadio;
		}

		public void setPayCountRadio(float payCountRadio) {
			this.payCountRadio = payCountRadio;
		}

		public int getKey() {
			return key;
		}

		public void setKey(int key) {
			this.key = key;
		}
	}
	
	// 付费对比数据类，Chart类
	public class PayCompareData {
		@ChartFlow(name="分类")
		private String classStr;  // 分类，选平台，就是所有平台，选渠道，就是所有渠道，选区服，就是所有区服
		private int payUser; // 付费人数
		@ChartSelect(name = "比例", key = 1)
		@ChartData1(name = "付费人数比例", key = 1)
		private float payUserRadio; // 付费人数比例
		private int payCount; // 付费金额
		@ChartData1(name = "付费金额比例", key = 1)
		private float payCountRadio; // 付费金额比例
		
		public final Comparator<PayCompareData> comparatorClass = new Comparator<PayCompareData>() {
			public int compare(PayCompareData s1, PayCompareData s2) {
				return s1.getClassStr().compareTo(s1.getClassStr());
			}
		};
		
		public String getClassStr() {
			return classStr;
		}

		public void setClassStr(String classStr) {
			this.classStr = classStr;
		}

		public int getPayUser() {
			return payUser;
		}

		public void setPayUser(int payUser) {
			this.payUser = payUser;
		}

		public float getPayUserRadio() {
			return payUserRadio;
		}

		public void setPayUserRadio(float payUserRadio) {
			this.payUserRadio = payUserRadio;
		}

		public int getPayCount() {
			return payCount;
		}

		public void setPayCount(int payCount) {
			this.payCount = payCount;
		}

		public float getPayCountRadio() {
			return payCountRadio;
		}

		public void setPayCountRadio(float payCountRadio) {
			this.payCountRadio = payCountRadio;
		}
	}
}
